<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
          integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css"
          integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
            integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</head>
<body>
<?php
session_start();
include '../query_mysql.php';
$qm=new query_mysql();
$_SESSION['selected_date']=$_REQUEST['date'];
$selected_date=$_SESSION['selected_date'];
$hall_id=$_SESSION['hall_id'];
echo "选择的日期：".$selected_date."<br>";
$conn=mysqli_connect('127.0.0.1','root','123456','tpp');
//选了日期以后看看这一天有哪些场次的电影
$sql_txt="select film_date_time from film_times where film_date='$selected_date' and hall_id='$hall_id'";
$result=mysqli_query($conn,$sql_txt);
echo "选择时间：";?>
<form action="../order/generate_order.php" method="get">
    <select name="time">
        <?php
        while ($info=mysqli_fetch_array($result)){
            $film_date_time=$info['film_date_time'];
            echo "<option value='$film_date_time'>$film_date_time</option>";
        }
        ?>
    </select>
    <br>
    <input type="button" onclick="check_available_tickets()" value="查看剩余的座位数">
    选择座位号
    <select name="seat_id">
        <?php
            $sql_txt_3="select * from seat_info where hall_id='$hall_id'";
            $result3=mysqli_query($conn,$sql_txt_3);
            while ($info3=mysqli_fetch_array($result3)){
                $seat_id=$info3['seat_id'];
                $is_ordered=$info3['is_ordered'];
                if ($is_ordered==0)
                    echo "<option value='$seat_id'>$seat_id</option>";
            }
        ?>
    </select>
    <br>
    座位分布图
    <br>
    <img src="../picture/seat.png" alt="1">
    <br>
    <input type="submit" value="生成订单">
</form>
<script>
    function check_available_tickets()
    {
        alert("你好，还有<?php
            $qm->query_sql("SELECT COUNT(*) from seat_info where hall_id='$hall_id' and is_ordered=0",'COUNT(*)');
            ?>个空位");
    }
</script>
</body>
</html>
<!--参考 https://www.jb51.net/article/33642.htm -->